package com.tvunetworks.center.user.model.vo;

import com.tvunetworks.center.common.util.JsonUtil;
import lombok.Data;

/**
 * @program: tvucc-user
 * @description: 分页显示用户Vo
 * @author lebronchen
 * @create: 2019-02-28 16:51
 **/
@Data
public class PageUserVo {

    private String id;
    private String email;
    private String accountType;
    private String active;
    private String phone;
    private String remark;
    private String createUserId;
    private String userParentId;
    private String userParentEmail;
    private int receiverCount;
    private int sourceCount;
    private String firstName;
    private String lastName;
    private String roleId;
    private String roleName;

    private boolean agreement;

    /**
     *
     * @return ExportUserVo
     */
    public ExportUserVo convertToExportUserVo(){
        ExportUserVo vo = JsonUtil.convertValue(this, ExportUserVo.class);
        vo.setStatus("1".equals(this.active) ? "Activate" : "Deactivate")
                .setAdminEmail(this.userParentEmail)
                .setAgreement(String.valueOf(this.agreement))
                .setRole("3".equals(this.accountType) ? "Customer Admin" : "Customer User");
        if (vo.getRemark() != null) {
            if (vo.getRemark().length() > 128) {
                vo.setRemark(vo.getRemark().substring(0, 128) + "...");
            }
        }
        return vo;
    }
}
